var u = Object.defineProperty;
var c = (o, t, e) =>
  t in o
    ? u(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e })
    : (o[t] = e);
var i = (o, t, e) => (c(o, typeof t != 'symbol' ? t + '' : t, e), e);
import { isScalar as y, isPair as h } from '../../nodes/identity.js';
import { toJS as d } from '../../nodes/toJS.js';
import { YAMLMap as p } from '../../nodes/YAMLMap.js';
import { YAMLSeq as g } from '../../nodes/YAMLSeq.js';
import { resolvePairs as v, createPairs as b } from './pairs.js';
const l = class l extends g {
  constructor() {
    super();
    i(this, 'add', p.prototype.add.bind(this));
    i(this, 'delete', p.prototype.delete.bind(this));
    i(this, 'get', p.prototype.get.bind(this));
    i(this, 'has', p.prototype.has.bind(this));
    i(this, 'set', p.prototype.set.bind(this));
    this.tag = l.tag;
  }
  /**
   * If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
   * but TypeScript won't allow widening the signature of a child method.
   */
  toJSON(e, s) {
    if (!s) return super.toJSON(e);
    const r = /* @__PURE__ */ new Map();
    s != null && s.onCreate && s.onCreate(r);
    for (const n of this.items) {
      let a, f;
      if (
        (h(n)
          ? ((a = d(n.key, '', s)), (f = d(n.value, a, s)))
          : (a = d(n, '', s)),
        r.has(a))
      )
        throw new Error('Ordered maps must not include duplicate keys');
      r.set(a, f);
    }
    return r;
  }
  static from(e, s, r) {
    const n = b(e, s, r),
      a = new this();
    return (a.items = n.items), a;
  }
};
i(l, 'tag', 'tag:yaml.org,2002:omap');
let m = l;
const O = {
  collection: 'seq',
  identify: o => o instanceof Map,
  nodeClass: m,
  default: !1,
  tag: 'tag:yaml.org,2002:omap',
  resolve(o, t) {
    const e = v(o, t),
      s = [];
    for (const { key: r } of e.items)
      y(r) &&
        (s.includes(r.value)
          ? t(`Ordered maps must not include duplicate keys: ${r.value}`)
          : s.push(r.value));
    return Object.assign(new m(), e);
  },
  createNode: (o, t, e) => m.from(o, t, e),
};
export { m as YAMLOMap, O as omap };
